jQuery(function($){
    var severeStyle;
    var severity;
    var status;
    var problemStyle;
    var row='';
	$.ajax({
		url: "alarming/queryAlarming.action",
		cache:"false",
		success: function(data){
		/*alert(JSON.stringify(data.length)); */
	       for(var i = 0; i < data.length; i++){    //获取后台传过来的url中的数据
            var id = data[i].id;
            var occurtime = data[i].occurtime;
            var violaterule = data[i].violaterule;
            var hostip = data[i].hostip;
            var rulestatus = data[i].rulestatus;
            var severe = data[i].severe;
            switch(rulestatus){
            case false:
            	problemStyle= 'status-metro status-problem';
            	status= 'problem';
            	break;
            case true:
            	problemStyle= 'status-metro status-ok';
            	status= 'ok';
                break;
    		
            };
            
            switch(severe){         //对违反规则的严重程度进行判断,并进行显式转换
    		case 1:
    			severeStyle = 'status-metro status-low';
    			severity = 'low';
    			break;
    		case 2:
    			severeStyle = 'status-metro status-warning';
    			severity = 'warning';
    		 	break;
    		case 3:
    			severeStyle = 'status-metro status-high';
    			severity = 'high';
    			break;
    		case 4:
    			severeStyle = 'status-metro status-higher';
    			severity = 'higher';
    			break;
    		case 5:
    			severeStyle = 'status-metro status-serious';
    			severity = 'serious';
    			break;
    		case 6:
    			severeStyle = 'status-metro status-disaster';
    			severity = 'disaster';
    			break;
    		default:
    			severeStyle = 'status-metro status-def';
    		    severity = 'normal';
    		};
    		
    		row += '<tr><td>' + id + '</td><td>' + occurtime + '</td><td>' + violaterule + '</td><td>'+hostip+'</td><td><span class="'+problemStyle+'">'+status+'</span></td><td><span class="'+severeStyle +'">'+ severity +'</span></td></tr>';
    		
	       };
	       $('tbody').html(row);//将每一行的数据加载到html中
	       console.log(row);
	       $('table').footable();//对footable进行初始化
	       /* var rowJson = JSON.parse(tableRow);//将拼接的字符串转化为json对象
	        console.log(rowJson);*/
	       
		}
});	

});
/*jQuery(function($){
//后台传过来的是json对象，需要将其转换成JavaScript对象
	$('#alarming_show').footable({
		"columns": $.get('documents/alarmingcolumns.json'),		
		 "rows": $.get('alarming/queryAlarming.action')
	});
});*/